package cn.aiyaun;

import java.io.FileInputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * @author wangyuan
 * @date 2021/8/23
 */
public class BufferTest1 {

    public static void main(String[] args) throws Exception {

        FileInputStream fileInputStream = new FileInputStream("D:\\environment\\IdeaProjects\\springboot-aiyuan\\noi-test\\src\\main\\resources\\1.txt");
        FileChannel channel = fileInputStream.getChannel();
        ByteBuffer allocate = ByteBuffer.allocate(1024);
        //从 channel 读取到buffer
        channel.read(allocate);
        allocate.flip();

        System.out.println(new String(allocate.array()));
    }

}
